var ControlSprite = cc.Sprite.extend({
	ctor:function(no){
		var x;
		var y;
		var picx;
		var picy;
		var position = GDposition(0,0);
		// 头端
		if(no==0){
			x=_GDselect.x;
			y=_GDselect.y;
			picx = 0;
			picy = 1;
			}
		// 末端
		else if(no == _GDway.length-1){
			x=_GDway[no].x;
			y=_GDway[no].y;
			if(_board[x][y]==null){
				if(_GDway[no-1].x == _GDway[no].x){
					if(_GDway[no].y == _GDway[no-1].y+1){
						picx = 7;
						picy = 0;
					}
					if(_GDway[no].y==_GDway[no-1].y-1){
						picx = 6;
						picy = 0;
					}
				}
				if(_GDway[no-1].y == _GDway[no].y){
					if(_GDway[no].x == _GDway[no-1].x+1){
						picx = 8;
						picy = 0;
					}
					if(_GDway[no].x==_GDway[no-1].x-1){
						picx = 9;
						picy = 0;
					}
				}				
			}
			else {
				if(_GDway[no-1].x == _GDway[no].x){
					if(_GDway[no].y == _GDway[no-1].y+1){
						picx = 6;
						picy = 1;
					}
					if(_GDway[no].y==_GDway[no-1].y-1){
						picx = 7;
						picy = 1;
					}
				}
				if(_GDway[no-1].y == _GDway[no].y){
					if(_GDway[no].x == _GDway[no-1].x+1){
						picx = 8;
						picy = 1;
					}
					if(_GDway[no].x==_GDway[no-1].x-1){
						picx = 9;
						picy = 1;
					}
				}
			}
		}
		// 中部
		else{
			x=_GDway[no].x;
			y=_GDway[no].y;
			if(_GDway[no-1].y == _GDway[no+1].y){
				picx = 0;
				picy = 0;
			}
			if(_GDway[no-1].x == _GDway[no+1].x){
				picx = 1;
				picy = 0;
			}
			if(_GDway[no-1].x == _GDway[no+1].x-1&&_GDway[no-1].y == _GDway[no+1].y-1){
				if(_GDway[no-1].x<_GDway[no].x){
					picx = 5;
					picy = 0;
				}
				if(_GDway[no].x<_GDway[no+1].x){
					picx = 3;
					picy = 0;
				}
			}
			if(_GDway[no-1].x == _GDway[no+1].x+1&&_GDway[no-1].y == _GDway[no+1].y+1){
				if(_GDway[no-1].x>_GDway[no].x){
					picx = 3;
					picy = 0;
				}
				if(_GDway[no].x>_GDway[no+1].x){
					picx = 5;
					picy = 0;
				}
			}
			if(_GDway[no-1].x == _GDway[no+1].x-1&&_GDway[no-1].y == _GDway[no+1].y+1){
				if(_GDway[no-1].x<_GDway[no].x){
					picx = 2;
					picy = 0;
				}
				if(_GDway[no].x<_GDway[no+1].x){
					picx = 4;
					picy = 0;
				}
			}
			if(_GDway[no-1].x == _GDway[no+1].x+1&&_GDway[no-1].y == _GDway[no+1].y-1){
				if(_GDway[no-1].x>_GDway[no].x){
					picx = 4;
					picy = 0;
				}
				if(_GDway[no].x>_GDway[no+1].x){
					picx = 2;
					picy = 0;
				}
			}
		}
		this._super(res.gc_move_png, cc.rect(picx*100, picy*100, 100, 100));
		this.setPosition(CChessPositionx(x),CChessPositiony(y));
		this.setLocalZOrder(50);
	}
});